package cn.tsoft.taobao.ui;

import java.util.ArrayList;
import java.util.Map;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import cn.tsoft.taobao.logic.ITaoBaoActivity;
import cn.tsoft.taobao.logic.TaskListActivity;

public class TradeOrderActivity extends  TaskListActivity implements ITaoBaoActivity {

	 //刷新交易订单
	  public static final int  REFRESH_TRADEORDER=1;
	  
	  public static final int REFRESH_ICON=2;
	
	@Override
	public void init() {

	}
	
	private ProgressDialog progressDialog = null;
    @SuppressWarnings("static-access")
	@Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
		   setContentView(R.layout.trade_list);
	  	  //添加到Activity组件集合
		   getStuffApplication().allActivity.add(this);
		   progressDialog = ProgressDialog.show(TradeOrderActivity.this, "请稍等...", "统计订单信息中...", true); 
	    }
	

	@SuppressWarnings({ "static-access", "unchecked" })
	@Override
	public void refresh(Object... param) {
		switch(((Integer)param[0]).intValue())
		{
		case -100://
			Toast.makeText(this,"获取失败", 1000).show();
			break;
		case REFRESH_TRADEORDER:
			ArrayList<Map<String,Object>>  contents = (ArrayList<Map<String,Object>> )param[1];
			String [] from = new String[]{"tradeState","tradeNum","tradeImage"};
			int[]  to = new int[]{R.id.trade_states,R.id.trade_num,R.id.trade_state_image};
			SimpleAdapter adapter = new SimpleAdapter(this,contents,R.layout.trade_order_item,from,to);
		    setListAdapter(adapter);
		    progressDialog.dismiss();
		    getStuffApplication().allActivity.remove(this);
		}
	}

}
